package androidx.lifecycle

import com.ppt.android.common.coroutine.RxLifeScope

private const val JOB_KEY = "androidx.lifecycle.ViewModelRxLifeScope.JOB_KEY"

val ViewModel.rxLifeScope: RxLifeScope
    get() {
        val scope: RxLifeScope? = this.getTag(JOB_KEY)
        if (scope != null) {
            return scope
        }
        return setTagIfAbsent(JOB_KEY, RxLifeScope())
    }

val LifecycleOwner.rxLifeScope: RxLifeScope
    get() = RxLifeScope(this)

val Lifecycle.rxLifeScope: RxLifeScope
    get() = RxLifeScope(this)